package com.fare.taluo.application.impl.crawl.crawlstatistics;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fare.taluo.application.crawl.crawlstatistics.FdcCrawlStatisticsForFlightLineApplication;
import com.fare.taluo.core.domain.crawl.FdcCrawlStatisticsForFlightLineEntity;
import com.fare.taluo.util.DateUtils;
import com.fare.taluo.vo.crawl.statistics.FdcCrawlStatisticsForFlightLineVo;
@Transactional
@Scope("singleton")
@Service("fdcCrawlStatisticsForFlightLineApplication")
public class FdcCrawlStatisticsForFlightLineApplicationImpl implements FdcCrawlStatisticsForFlightLineApplication{

	@Override
	public List<FdcCrawlStatisticsForFlightLineVo> findForFlightLineVo(String fromCityCode, String toCityCode) {
		List<FdcCrawlStatisticsForFlightLineVo> listVo=new ArrayList<FdcCrawlStatisticsForFlightLineVo>();
		FdcCrawlStatisticsForFlightLineEntity tp=new FdcCrawlStatisticsForFlightLineEntity();
		List<FdcCrawlStatisticsForFlightLineEntity> listEntity=tp.findFlightLineEntityByCityCode(fromCityCode, toCityCode);
		if(listEntity.size()>0){
			for(FdcCrawlStatisticsForFlightLineEntity entity:listEntity){
				FdcCrawlStatisticsForFlightLineVo vo=new FdcCrawlStatisticsForFlightLineVo();
				vo.setId(Long.parseLong(entity.getId()));
				vo.setCreateTime(entity.getCreateTime());
				vo.setFromCity(entity.getFromCity());
				vo.setFromCityName(entity.getFromCityName());
				vo.setToCity(entity.getToCity());
				vo.setToCityName(entity.getToCityName());
				vo.setGrabEndDate(entity.getGrabEndDate());
				vo.setGrabStartDate(entity.getGrabStartDate());
				vo.setGrabStartDateStr(entity.getGrabStartDate() !=null?DateUtils.dateToStr(entity.getGrabStartDate(),"yyyy-MM-dd"):null);
				vo.setGrabEndDateStr(entity.getGrabEndDate() !=null?DateUtils.dateToStr(entity.getGrabEndDate(),"yyyy-MM-dd"):null);
				vo.setGrabTotalSource(entity.getGrabTotalSource());
				
				listVo.add(vo);
			}
			
		}
		
		return listVo;
	}

}
